"use client"; // Make sure this is a client component for using useRouter

import React, { ReactNode, RefAttributes, Suspense } from "react";
import "../globals.css";
import {
  SidebarInset,
  SidebarProvider,
  SidebarTrigger,
} from "@/components/ui/sidebar";
import { Separator } from "@/components/ui/separator";
import { AppSidebar, ISidebarMenu } from "@/components/app-sidebar";
import BreadCrumb from "@/components/bread-crumb";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import Navbar from "@/components/nav-bar";

export const dynamic = "force-static";
import {
  PieChartIcon,
  DashboardIcon,
  TransformIcon,
  CookieIcon,
  Link1Icon,
  TargetIcon,
} from "@radix-ui/react-icons";
interface RootLayoutProps {
  children: ReactNode;
}
const data: ISidebarMenu = {
  versions: ["0.1.0"],
  navMain: [
    {
      title: "控制面板",
      url: "#",
      icon: DashboardIcon,
      items: [
        { title: "任务管理", url: "/task", icon: TransformIcon },
        {
          title: "平台管理",
          url: "/platform",
          icon: TargetIcon,
        },
        {
          title: "Cookie管理",
          url: "/cookies",
          icon: CookieIcon,
        },

        {
          title: "代理管理",
          url: "/proxies",
          icon: Link1Icon,
        },
        {
          title: "统计信息",
          url: "/goods",
          icon: PieChartIcon,
        },
      ],
    },
  ],
};
const queryClient = new QueryClient();
export default function RootLayout({ children }: RootLayoutProps) {
  return (
    <SidebarProvider>
      <AppSidebar collapsible={"icon"} menus={data} />
      <SidebarInset className="h-full peer-data-[variant=inset]">
        <Navbar />
        <header className="flex h-16 shrink-0 items-center gap-2 border-b px-4">
          <SidebarTrigger className="-ml-1" />
          <Separator orientation="vertical" className="mr-2 h-4" />
          <BreadCrumb />
        </header>
        <QueryClientProvider client={queryClient}>
          <Suspense>{children}</Suspense>
        </QueryClientProvider>
      </SidebarInset>
    </SidebarProvider>
  );
}
